/*
 * PhotoPanel.java
 *
 * Created on 09-mar-2009, 0:58:06
 */
package grupb.upf.gui;

import grupb.upf.XMLObjects.Photo;
import grupb.upf.XMLObjects.Tag;
import grupb.upf.XMLObjects.Tagging;
import grupb.upf.XMLObjects.impl.PersonalTag;
import grupb.upf.XMLObjects.impl.PredefinedTag;
import grupb.upf.imageProcessing.TagAnnotation;
import grupb.upf.imageProcessing.Blurring;
import grupb.upf.imageProcessing.Brightness;
import grupb.upf.imageProcessing.Contrast;
import grupb.upf.imageProcessing.DisplayJAIWithAnnotations;
import grupb.upf.imageProcessing.Sharp;
import grupb.upf.imageProcessing.EdgeDetection;
import grupb.upf.imageProcessing.Store;
import java.awt.Color;
import java.io.File;
import java.util.Collections;
import java.util.List;
import java.util.Vector;
import javax.media.jai.JAI;
import javax.media.jai.PlanarImage;
import javax.swing.DefaultListModel;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileSystemView;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * <p>This class contains the photo edition.</p>
 *
 * @version    0.0.1-SNAPSHOT
 * @author Group B
 */
public class PhotoPanel extends javax.swing.JPanel {

    /**
     * The logger. A new logger <code>grupb.upf.gui.PhotoPanel</code>
     * is created to add the logs of this PhotoPanel
     */
    private static final Log LOG = LogFactory.getLog(PhotoPanel.class);
    /**
     * The planar image to be shown.
     */
    private PlanarImage image;
    /**
     * The history index to undo and redo.
     */
    private int historyIndex = 0;
    /**
     * The image to change.
     */
    private DisplayJAIWithAnnotations img;
    /**
     * The history of actions.
     */
    private List < Object[] > history;
    /**
     * The file.
     */
    private File file;
    /**
     * The auxiliar file.
     */
    private File auxFile;
    /**
     * The principal GUI.
     */
    private P2Piki p2piki;
    /**
     * The photo that we are editing.
     */
    private Photo photo;
    /**
     * The list of tags.
     */
    private List < Tag > auxTagsList = new Vector();
    /**
     * The list of edited tags.
     */
    private List < Tag > auxEditedTagsList = new Vector();
    /**
     * The default list model of edited tags.
     */
    private DefaultListModel editedTagsModel = new DefaultListModel();
    /**
     * if we are tagging regions it will be true.
     */
    private boolean paintTags = false;
    /**
     * The type of photos format accepted.
     */
    private static final String [] PHOTO_FORMATS =
    {"jpg", "jpeg", "gif", "png"};
    /**
     * The list of Taxonomies.
     */
    private List taxonomies;
    /**
     * The region tag points.
     */
    private int[] coordenates;

    /**
     * The constructor of the class.
     * @param p2p the principal GUI
     */
    public PhotoPanel(final P2Piki p2p) {
        this.p2piki = p2p;
        initComponents();
    }

    /**
     * Method to set up the categories of the ontologies, we receive it from
     * the main class.
     * @param t the complete t
     */
    public void initCategories(final List t) {
        taxonomies = t;
        List tax;
        categoriesComboBox.removeAllItems();
        categoriesComboBox.addItem("Choose a category");
        for (int i = 0; i < t.size(); i++) {
            tax = (List) t.get(i);
            categoriesComboBox.addItem((String) tax.get(0));
        }
    }

    /**
     * Method to set a photo into this panel.
     * @param f the photo
     */
    public void setPhoto(final File f) {
        this.file = f.getAbsoluteFile();
        this.image = JAI.create("fileload", f.getAbsolutePath());
        this.img = new DisplayJAIWithAnnotations(image, p2piki);
        historyIndex = 0;
        history = new Vector();
        img.set(image);
        photoEditionPanel.removeAll();
        photoScrollPane = new javax.swing.JScrollPane(img);
        setScrollPaneSize();
        photoEditionPanel.add(photoScrollPane);
        update();
        Object[] a = {"fileload", image, contrastSlider.getValue(),
        brightnessSlider.getValue()};
        history.add(a);
        undoButton.setEnabled(false);
        redoButton.setEnabled(false);
        qualitySlider.setValue(100);
        qualityTextField.setText("100");
        contrastSlider.setValue(0);
        contrastTextField.setText("0");
        brightnessSlider.setValue(1);
        brightnessTextField.setText("1");
        getProperties();
    }

    /**
     * Method to update the properties of a photo.
     */
    public void updateProperties() {
        updatePhotoProperties();
        if (photo != null) {
            final boolean flag = p2piki.updatePhoto(photo);
            if (flag) {
                p2piki.addInfo("Photo updated correctly.");
            } else {
                p2piki.addError("Error updating the photo.");
            }
        } else {
            p2piki.addError("Error, it was impossible to update the properties because it isn't in the Database.");
        }
    }
    /**
     * Method to update the photo properties.
     */
    private void updatePhotoProperties() {
        photo.getMetadataDC().setContentProperty("dc.title", title.getText()
                .trim());
        titleView.setText(photo.getMetadataDC()
                .getContentProperty("dc.title"));
        if (photo.getMetadataDC()
                .getInstantiationProperty("dc.date") != null) {
            dateView.setText(getDate(photo.getMetadataDC()
                .getInstantiationProperty("dc.date")));
        }
        photo.getMetadataDC().setContentProperty("dc.subject", subject
                .getText().trim());
        photo.getMetadataDC().setContentProperty("dc.description", description
                .getText().trim());
        photo.getMetadataDC().setContentProperty("dc.source", source.getText()
                .trim());
        photo.getMetadataDC().setIntellectualProperty("dc.creator", creator
                .getText().trim());
        photo.getMetadataDC().setIntellectualProperty("dc.publisher", publisher
                .getText().trim());
        photo.getMetadataDC().setIntellectualProperty("dc.contributor",
                contributor.getText().trim());
        photo.getMetadataDC().setIntellectualProperty("dc.rights", rights
                .getText().trim());
        final List predefinedTags = new Vector();
        final List personalTags = new Vector();
        for (int i = 0; i < auxTagsList.size(); i++) {
            if (auxTagsList.get(i) instanceof PredefinedTag) {
                predefinedTags.add(auxTagsList.get(i));
            } else if (auxTagsList.get(i) instanceof PersonalTag) {
                personalTags.add(auxTagsList.get(i));
            }
        }
        photo.getTags().setPredefinedTags(predefinedTags);
        photo.getTags().setPersonalTags(personalTags);
    }
    /**
     * Method to add a new photo to the DB.
     * @param f the file
     * @param p the photo properties
     */
    public void newPhoto(final File f, Photo p) {
        photo = p;
        newPhoto(f);
    }

    /**
     * Method to add a new photo to the DB.
     * @param f the file, the photo properties are loaded to the parameter
     * photo
     */
    public void newPhoto(final File f) {
        String path = f.getAbsolutePath().replaceAll("\\\\", "/");
        int index = path.indexOf(grupb.upf.util.Config.getProperty(
                "photo.folder")) +
                grupb.upf.util.Config.getProperty("photo.folder").length();
        path = path.substring(index);
        updatePhotoProperties();
        photo.setID(-1);
        photo.setURL(path);
        if (LOG.isInfoEnabled()) {
            final StringBuffer sb = new StringBuffer(
                    "We insert the new photo to the DB: ")
                    .append(path);
            LOG.info(sb);
        }
        final boolean flag = p2piki.addPhoto(photo);
        if (flag) {
            p2piki.addInfo("Photo inserted to the database");
        } else {
            p2piki.addError("Error inserting the photo to the database.");
        }
    }

    /**
     * Method to get the properties and show them.
     */
    private void getProperties() {
        String path = file.getAbsolutePath().replaceAll("\\\\", "/");
        int index = path.indexOf(grupb.upf.util.Config.getProperty(
                "photo.folder")) +
                grupb.upf.util.Config.getProperty("photo.folder").length();
        path = path.substring(index);
        photo = p2piki.getPhoto(path);
        if (photo != null) {
            titleView.setText(photo.getMetadataDC()
                    .getContentProperty("dc.title"));
            dateView.setText(getDate(photo.getMetadataDC()
                    .getInstantiationProperty("dc.date")));
            title.setText(photo.getMetadataDC()
                    .getContentProperty("dc.title"));
            subject.setText(photo.getMetadataDC()
                    .getContentProperty("dc.subject"));
            description.setText(photo.getMetadataDC()
                    .getContentProperty("dc.description"));
            source.setText(photo.getMetadataDC()
                    .getContentProperty("dc.source"));
            creator.setText(photo.getMetadataDC()
                    .getIntellectualProperty("dc.creator"));
            publisher.setText(photo.getMetadataDC()
                    .getIntellectualProperty("dc.publisher"));
            contributor.setText(photo.getMetadataDC()
                    .getIntellectualProperty("dc.contributor"));
            rights.setText(photo.getMetadataDC()
                    .getIntellectualProperty("dc.rights"));
            Tagging tags = photo.getTags();
            List<Tag> listOfTags = tags.getPersonalTags();
            auxTagsList = new Vector();
            auxEditedTagsList = new Vector();
            editedTagsModel.removeAllElements();
            tagsComboBox.removeAllItems();
            tagsComboBox.addItem("-------------------- Tags ---------------------");
            for (int i = 0; i < listOfTags.size(); i++) {
                auxTagsList.add(listOfTags.get(i));
                auxEditedTagsList.add(listOfTags.get(i));
                tagsComboBox.addItem(listOfTags.get(i).getTag());
                editedTagsModel.addElement(
                        (String) listOfTags.get(i).getTag());
            }
            listOfTags = tags.getPredefinedTags();
            for (int i = 0; i < listOfTags.size(); i++) {
                auxTagsList.add(listOfTags.get(i));
                auxEditedTagsList.add(listOfTags.get(i));
                tagsComboBox.addItem(listOfTags.get(i).getTag());
                editedTagsModel.addElement(
                        (String) listOfTags.get(i).getTag());
            }
        } else {
            if (LOG.isInfoEnabled()) {
                final StringBuffer sb = new StringBuffer(
                        "The image isn't in the database: ")
                        .append(path);
                LOG.info(sb);
            }
            photo = new grupb.upf.XMLObjects.impl.Photo();
            photo.setMetadataDC(new grupb.upf.XMLObjects.impl.MetadataDC());
            Tagging tags = new grupb.upf.XMLObjects.impl.Tagging();
            tags.setPersonalTags(new Vector());
            tags.setPredefinedTags(new Vector());
            photo.setTags(tags);
            photo.setID(-1);
            titleView.setText("");
            dateView.setText("");
            title.setText("");
            subject.setText("");
            description.setText("");
            source.setText("");
            creator.setText("");
            publisher.setText("");
            contributor.setText("");
            rights.setText("");
            auxTagsList = new Vector();
            auxEditedTagsList = new Vector();
            editedTagsModel.removeAllElements();
            tagsComboBox.removeAllItems();
            tagsComboBox.addItem("-------------------- Tags ---------------------");
            p2piki.addWarning("This photo isn't stored in the database,\nthe changes about tags and the metadata of the photo \naren't going to be saved if you don't save it in the P2Piki's folder.");
        }
    }

    /**
     * Method to delete a photo from the DB and physically.
     */
    public boolean deletePhoto() {
        //La guardo y así me aseguro que los streams y tal están cerrados.
        Store s = new Store();
        s.store(file.getAbsolutePath(), image, 50);
        boolean deleted = false;
        for (int i = 0; i < 100 && !deleted; i++) {
            if(file.delete()) {
                deleted = true;
            }
        }
        if (deleted) {
            if (photo != null && photo.getID() != -1) {
                final boolean flag = p2piki.deletePhoto(photo.getID());
                if (flag) {
                    if (LOG.isInfoEnabled()) {
                        LOG.info("Photo deleted correctly.");
                    }
                    p2piki.addInfo("Photo deleted correctly.");
                } else {
                    if (LOG.isErrorEnabled()) {
                        LOG.error("Error deleting the photo from the DB.");
                    }
                    p2piki.addError("Error deleting the photo from the DB.");
                }
            } else {
                if (LOG.isInfoEnabled()) {
                    LOG.info("The photo isnt't in the database");
                }
            }
        } else {
            if (LOG.isErrorEnabled()) {
                LOG.error("Error deleting the image, maybe it is being used by another application.");
                }
            p2piki.addError("Error deleting the image,\nmaybe it is being used by another application.");
        }
        return deleted;
    }

    /**
     * Method to store the properties of a photo.
     */
    private void storePhotoData() {
        if (auxFile != null) {
            String path = auxFile.getAbsolutePath().replaceAll("\\\\", "/");
            if (LOG.isInfoEnabled()) {
                StringBuffer sb = new StringBuffer("Storing file: ")
                        .append(path + " / " + grupb.upf.util.Config
                        .getProperty("photo.folder"));
                LOG.info(sb);
            }
            if (path.indexOf(grupb.upf.util
                    .Config.getProperty("photo.folder")) != -1) {
                newPhoto(auxFile);
            } else {
                if (LOG.isWarnEnabled()) {
                StringBuffer sb = new StringBuffer("File ")
                        .append(path)
                        .append(" stored outside the P2Piki's folder.");
                LOG.warn(sb);
                }
                p2piki.addWarning("The image has been stored outside the P2Piki's folder,\nas a result, its data hasn't been stored in the database.");
            }
            setPhoto(auxFile);
        }
    }
    /**
     * Method to set up the size of the scrollPane that contains the photo.
     */
    private void setScrollPaneSize() {
        if (img.getWidth() > 400) {
            photoScrollPane.setHorizontalScrollBarPolicy(
                    javax.swing.ScrollPaneConstants
                    .HORIZONTAL_SCROLLBAR_ALWAYS);
        }
        if (img.getHeight() > 250) {
            photoScrollPane.setVerticalScrollBarPolicy(
                    javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        }
    }

    /**
     * Method to update the undo and redo options.
     */
    private void updateHistory() {
        img.removeAnnotations();
        for (int i = history.size() - 1; i > historyIndex; i--) {
            history.remove(i);
        }
        historyIndex++;
    }

    /**
     * Method to update the view.
     */
    private void update() {
        p2piki.repaint();
    }

    /**
     * Method to get the date from an existent String date.
     * @param date the date in String format (YYYYMMDD)
     * @return the date formatted to (DD-MM-YYYY)
     */
    private String getDate(final String date) {
        String newDate = "(" + date.substring(6, 8) + "/" +
                date.substring(4, 6) + "/" + date.substring(0, 4) + ")";
        return newDate;
    }

    /**
     * Method to remove the stored annotations.
     */
    private void removeAnnotations() {
        img.removeAnnotations();
        image = (PlanarImage) history.get(historyIndex)[1];
        img.set(image);
        update();
    }

    /**
     * Method to know if we are painting a region tag or not.
     * @return
     */
    public boolean isPaintEnabled() {
        return paintTags;
    }

    /**
     * Method to set up the coordenates of a region tag.
     * @param points the points of the tag
     */
    public void setCoordenates(final int[] points) {
        coordenates = points;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        ontologiesPopupMenu = new javax.swing.JPopupMenu();
        desktopPane = new javax.swing.JDesktopPane();
        contrastInternalFrame = new javax.swing.JInternalFrame();
        contrastPanel = new javax.swing.JPanel();
        contrastSlider = new javax.swing.JSlider();
        contrastTextField = new javax.swing.JTextField();
        previewButton = new javax.swing.JCheckBox();
        acceptButton = new javax.swing.JButton();
        cancelButton = new javax.swing.JButton();
        brightnessPanel = new javax.swing.JPanel();
        brightnessSlider = new javax.swing.JSlider();
        brightnessTextField = new javax.swing.JTextField();
        previewButton1 = new javax.swing.JCheckBox();
        qualityInternalFrame = new javax.swing.JInternalFrame();
        qualityOkButton = new javax.swing.JButton();
        qualityCancelButton = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        qualitySlider = new javax.swing.JSlider();
        qualityTextField = new javax.swing.JTextField();
        deletePreviousInternalFrame = new javax.swing.JInternalFrame();
        deleteYesButton1 = new javax.swing.JButton();
        deleteNoButton1 = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        deleteInternalFrame = new javax.swing.JInternalFrame();
        deleteYesButton = new javax.swing.JButton();
        deleteNoButton = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        addTagInternalFrame = new javax.swing.JInternalFrame();
        addTagTabbedPane = new javax.swing.JTabbedPane();
        personalTagPanel = new javax.swing.JPanel();
        addTagTextField = new javax.swing.JTextField();
        addPersonalTagButton = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        regionOntologyTag1 = new javax.swing.JButton();
        ontologyTagPanel = new javax.swing.JPanel();
        addOntologyTagButton = new javax.swing.JButton();
        addOntologyTagTextField = new javax.swing.JTextField();
        categoryLabel = new javax.swing.JLabel();
        regionOntologyTag = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        categoriesComboBox = new javax.swing.JComboBox();
        cancelTagButton = new javax.swing.JButton();
        acceptTagButton = new javax.swing.JButton();
        editedTagsScrollPane = new javax.swing.JScrollPane();
        editedTagsList = new javax.swing.JList();
        deleteTagButton = new javax.swing.JButton();
        editionPanelContainer = new javax.swing.JPanel();
        editionPanel = new javax.swing.JPanel();
        photoEditionPanel = new javax.swing.JPanel();
        photoScrollPane = new javax.swing.JScrollPane();
        palettePanel = new javax.swing.JPanel();
        optionsPanel = new javax.swing.JPanel();
        saveButton = new javax.swing.JButton();
        openImageButton = new javax.swing.JButton();
        openImageButton1 = new javax.swing.JButton();
        undoButton = new javax.swing.JButton();
        sharpButton = new javax.swing.JButton();
        blurButton = new javax.swing.JButton();
        contrastButton = new javax.swing.JButton();
        redoButton = new javax.swing.JButton();
        edgeDetectionButton = new javax.swing.JButton();
        deleteButton = new javax.swing.JButton();
        titleView = new javax.swing.JLabel();
        dateView = new javax.swing.JLabel();
        addTagButton = new javax.swing.JButton();
        tagsComboBox = new javax.swing.JComboBox();
        tagsLabel = new javax.swing.JLabel();
        metadataPanel = new javax.swing.JPanel();
        updatePropertiesButton = new javax.swing.JButton();
        generalPanel = new javax.swing.JPanel();
        titleLabel = new javax.swing.JLabel();
        title = new javax.swing.JTextField();
        subjectLabel = new javax.swing.JLabel();
        subject = new javax.swing.JTextField();
        descriptionLabel = new javax.swing.JLabel();
        source = new javax.swing.JTextField();
        sourceLabel = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        description = new javax.swing.JTextArea();
        intellectualpanel = new javax.swing.JPanel();
        creatorLabel = new javax.swing.JLabel();
        publisherLabel = new javax.swing.JLabel();
        publisher = new javax.swing.JTextField();
        creator = new javax.swing.JTextField();
        contributorLabel = new javax.swing.JLabel();
        contributor = new javax.swing.JTextField();
        rights = new javax.swing.JTextField();
        rightsLabel = new javax.swing.JLabel();
        resetPropertiesButton = new javax.swing.JButton();

        ontologiesPopupMenu.setAutoscrolls(true);
        ontologiesPopupMenu.setMaximumSize(new java.awt.Dimension(260, 100));

        setBackground(new java.awt.Color(255, 255, 255));
        setPreferredSize(new java.awt.Dimension(534, 595));

        desktopPane.setMaximumSize(new java.awt.Dimension(546, 556));
        desktopPane.setMinimumSize(new java.awt.Dimension(546, 556));

        contrastInternalFrame.setTitle("Contrast / Brightness");
        contrastInternalFrame.setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/p2pikiLogo.png"))); // NOI18N
        contrastInternalFrame.setLayer(300);
        contrastInternalFrame.setMinimumSize(new java.awt.Dimension(407, 209));
        contrastInternalFrame.setNormalBounds(new java.awt.Rectangle(100, 200, 407, 209));

        contrastPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Contrast"));

        contrastSlider.setMaximum(250);
        contrastSlider.setMinimum(-250);
        contrastSlider.setValue(0);
        contrastSlider.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                contrastSliderMouseDragged(evt);
            }
        });

        contrastTextField.setText("0");
        contrastTextField.setAutoscrolls(false);
        contrastTextField.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        contrastTextField.setEnabled(false);

        previewButton.setSelected(true);
        previewButton.setText("Preview");

        javax.swing.GroupLayout contrastPanelLayout = new javax.swing.GroupLayout(contrastPanel);
        contrastPanel.setLayout(contrastPanelLayout);
        contrastPanelLayout.setHorizontalGroup(
            contrastPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(contrastPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(contrastPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(previewButton)
                    .addGroup(contrastPanelLayout.createSequentialGroup()
                        .addComponent(contrastSlider, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(6, 6, 6)
                        .addComponent(contrastTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(18, Short.MAX_VALUE))
        );
        contrastPanelLayout.setVerticalGroup(
            contrastPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(contrastPanelLayout.createSequentialGroup()
                .addGroup(contrastPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(contrastTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(contrastSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(previewButton))
        );

        acceptButton.setText("Accept");
        acceptButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                acceptButtonActionPerformed(evt);
            }
        });

        cancelButton.setText("Cancel");
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelButtonActionPerformed(evt);
            }
        });

        brightnessPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Brightness"));

        brightnessSlider.setMaximum(3);
        brightnessSlider.setMinimum(1);
        brightnessSlider.setValue(1);
        brightnessSlider.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                brightnessSliderMouseDragged(evt);
            }
        });

        brightnessTextField.setText("5");
        brightnessTextField.setAutoscrolls(false);
        brightnessTextField.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        brightnessTextField.setEnabled(false);

        previewButton1.setSelected(true);
        previewButton1.setText("Preview");

        javax.swing.GroupLayout brightnessPanelLayout = new javax.swing.GroupLayout(brightnessPanel);
        brightnessPanel.setLayout(brightnessPanelLayout);
        brightnessPanelLayout.setHorizontalGroup(
            brightnessPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(brightnessPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(brightnessPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(previewButton1)
                    .addGroup(brightnessPanelLayout.createSequentialGroup()
                        .addComponent(brightnessSlider, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(6, 6, 6)
                        .addComponent(brightnessTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(18, Short.MAX_VALUE))
        );
        brightnessPanelLayout.setVerticalGroup(
            brightnessPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(brightnessPanelLayout.createSequentialGroup()
                .addGroup(brightnessPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(brightnessTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(brightnessSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(previewButton1))
        );

        javax.swing.GroupLayout contrastInternalFrameLayout = new javax.swing.GroupLayout(contrastInternalFrame.getContentPane());
        contrastInternalFrame.getContentPane().setLayout(contrastInternalFrameLayout);
        contrastInternalFrameLayout.setHorizontalGroup(
            contrastInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(contrastInternalFrameLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(contrastInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(brightnessPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(contrastPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(contrastInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(acceptButton, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
                    .addComponent(cancelButton, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE))
                .addContainerGap())
        );
        contrastInternalFrameLayout.setVerticalGroup(
            contrastInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(contrastInternalFrameLayout.createSequentialGroup()
                .addGroup(contrastInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(contrastInternalFrameLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(contrastPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(brightnessPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(contrastInternalFrameLayout.createSequentialGroup()
                        .addGap(63, 63, 63)
                        .addComponent(acceptButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cancelButton)))
                .addContainerGap(35, Short.MAX_VALUE))
        );

        contrastInternalFrame.setBounds(100, 200, 407, 233);
        desktopPane.add(contrastInternalFrame, javax.swing.JLayeredPane.POPUP_LAYER);

        qualityInternalFrame.setTitle("Delete an image");
        qualityInternalFrame.setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/p2pikiLogo.png"))); // NOI18N
        qualityInternalFrame.setMaximumSize(new java.awt.Dimension(285, 150));
        qualityInternalFrame.setMinimumSize(new java.awt.Dimension(285, 150));
        qualityInternalFrame.setNormalBounds(new java.awt.Rectangle(100, 200, 285, 150));
        qualityInternalFrame.setPreferredSize(new java.awt.Dimension(285, 150));

        qualityOkButton.setText("Accept");
        qualityOkButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                qualityOkButtonActionPerformed(evt);
            }
        });

        qualityCancelButton.setText("Cancel");
        qualityCancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                qualityCancelButtonActionPerformed(evt);
            }
        });

        jLabel5.setText("Select the quality to store the image");

        qualitySlider.setValue(100);
        qualitySlider.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                qualitySliderMouseDragged(evt);
            }
        });

        qualityTextField.setText("100");
        qualityTextField.setAutoscrolls(false);
        qualityTextField.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        qualityTextField.setEnabled(false);

        javax.swing.GroupLayout qualityInternalFrameLayout = new javax.swing.GroupLayout(qualityInternalFrame.getContentPane());
        qualityInternalFrame.getContentPane().setLayout(qualityInternalFrameLayout);
        qualityInternalFrameLayout.setHorizontalGroup(
            qualityInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(qualityInternalFrameLayout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addGroup(qualityInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addGroup(qualityInternalFrameLayout.createSequentialGroup()
                        .addGroup(qualityInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(qualityInternalFrameLayout.createSequentialGroup()
                                .addComponent(qualityOkButton)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(qualityCancelButton))
                            .addComponent(qualitySlider, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(qualityTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(41, Short.MAX_VALUE))
        );
        qualityInternalFrameLayout.setVerticalGroup(
            qualityInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(qualityInternalFrameLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addGap(18, 18, 18)
                .addGroup(qualityInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(qualitySlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(qualityInternalFrameLayout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(qualityTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
                .addGroup(qualityInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(qualityOkButton)
                    .addComponent(qualityCancelButton))
                .addContainerGap())
        );

        qualityInternalFrame.setBounds(100, 200, 285, 150);
        desktopPane.add(qualityInternalFrame, javax.swing.JLayeredPane.POPUP_LAYER);
        qualityInternalFrame.getAccessibleContext().setAccessibleName("Select the quality");

        deletePreviousInternalFrame.setTitle("Delete an image");
        deletePreviousInternalFrame.setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/p2pikiLogo.png"))); // NOI18N
        deletePreviousInternalFrame.setPreferredSize(new java.awt.Dimension(263, 114));

        deleteYesButton1.setText("Yes");
        deleteYesButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteYesButton1ActionPerformed(evt);
            }
        });

        deleteNoButton1.setText("No");
        deleteNoButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteNoButton1ActionPerformed(evt);
            }
        });

        jLabel4.setText("Do you want to delete the old image?");

        javax.swing.GroupLayout deletePreviousInternalFrameLayout = new javax.swing.GroupLayout(deletePreviousInternalFrame.getContentPane());
        deletePreviousInternalFrame.getContentPane().setLayout(deletePreviousInternalFrameLayout);
        deletePreviousInternalFrameLayout.setHorizontalGroup(
            deletePreviousInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, deletePreviousInternalFrameLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(deletePreviousInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(deletePreviousInternalFrameLayout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addComponent(deleteYesButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(deleteNoButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(30, 30, 30))
        );
        deletePreviousInternalFrameLayout.setVerticalGroup(
            deletePreviousInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, deletePreviousInternalFrameLayout.createSequentialGroup()
                .addContainerGap(17, Short.MAX_VALUE)
                .addComponent(jLabel4)
                .addGap(18, 18, 18)
                .addGroup(deletePreviousInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(deleteYesButton1)
                    .addComponent(deleteNoButton1))
                .addContainerGap())
        );

        deletePreviousInternalFrame.setBounds(150, 150, 210, 110);
        desktopPane.add(deletePreviousInternalFrame, javax.swing.JLayeredPane.POPUP_LAYER);

        deleteInternalFrame.setTitle("Delete an image");
        deleteInternalFrame.setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/p2pikiLogo.png"))); // NOI18N
        deleteInternalFrame.setMaximumSize(new java.awt.Dimension(200, 114));
        deleteInternalFrame.setMinimumSize(new java.awt.Dimension(200, 114));

        deleteYesButton.setText("Yes");
        deleteYesButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteYesButtonActionPerformed(evt);
            }
        });

        deleteNoButton.setText("No");
        deleteNoButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteNoButtonActionPerformed(evt);
            }
        });

        jLabel3.setText("Are you sure to delete this image?");

        javax.swing.GroupLayout deleteInternalFrameLayout = new javax.swing.GroupLayout(deleteInternalFrame.getContentPane());
        deleteInternalFrame.getContentPane().setLayout(deleteInternalFrameLayout);
        deleteInternalFrameLayout.setHorizontalGroup(
            deleteInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(deleteInternalFrameLayout.createSequentialGroup()
                .addGroup(deleteInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(deleteInternalFrameLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel3))
                    .addGroup(deleteInternalFrameLayout.createSequentialGroup()
                        .addGap(38, 38, 38)
                        .addComponent(deleteYesButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(deleteNoButton)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        deleteInternalFrameLayout.setVerticalGroup(
            deleteInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, deleteInternalFrameLayout.createSequentialGroup()
                .addContainerGap(24, Short.MAX_VALUE)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(deleteInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(deleteYesButton)
                    .addComponent(deleteNoButton))
                .addContainerGap())
        );

        deleteInternalFrame.setBounds(50, 50, 190, 110);
        desktopPane.add(deleteInternalFrame, javax.swing.JLayeredPane.POPUP_LAYER);

        addTagInternalFrame.setTitle("Edit tags");
        addTagInternalFrame.setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/p2pikiLogo.png"))); // NOI18N
        addTagInternalFrame.setMaximumSize(new java.awt.Dimension(401, 250));
        addTagInternalFrame.setMinimumSize(new java.awt.Dimension(401, 250));
        addTagInternalFrame.setPreferredSize(new java.awt.Dimension(401, 250));
        addTagInternalFrame.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                addTagInternalFrameFocusLost(evt);
            }
        });

        addTagTabbedPane.setMaximumSize(new java.awt.Dimension(211, 180));
        addTagTabbedPane.setMinimumSize(new java.awt.Dimension(211, 180));
        addTagTabbedPane.setPreferredSize(new java.awt.Dimension(211, 180));

        personalTagPanel.setBackground(new java.awt.Color(255, 255, 255));
        personalTagPanel.setMaximumSize(new java.awt.Dimension(209, 152));
        personalTagPanel.setMinimumSize(new java.awt.Dimension(209, 152));

        addPersonalTagButton.setText("Add Tag");
        addPersonalTagButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addPersonalTagButtonActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Tahoma", 2, 11));
        jLabel2.setText("Optional");

        regionOntologyTag1.setText("Select a Region");
        regionOntologyTag1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                regionOntologyTag1ActionPerformed(evt);
            }
        });
        regionOntologyTag1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                regionOntologyTag1FocusLost(evt);
            }
        });

        javax.swing.GroupLayout personalTagPanelLayout = new javax.swing.GroupLayout(personalTagPanel);
        personalTagPanel.setLayout(personalTagPanelLayout);
        personalTagPanelLayout.setHorizontalGroup(
            personalTagPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(personalTagPanelLayout.createSequentialGroup()
                .addGroup(personalTagPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(personalTagPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(personalTagPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(addTagTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(regionOntologyTag1, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(personalTagPanelLayout.createSequentialGroup()
                        .addGap(58, 58, 58)
                        .addComponent(addPersonalTagButton, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        personalTagPanelLayout.setVerticalGroup(
            personalTagPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(personalTagPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(addTagTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(regionOntologyTag1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 26, Short.MAX_VALUE)
                .addComponent(addPersonalTagButton)
                .addContainerGap())
        );

        addTagTabbedPane.addTab("Personal Tag", personalTagPanel);

        ontologyTagPanel.setBackground(new java.awt.Color(255, 255, 255));
        ontologyTagPanel.setMaximumSize(new java.awt.Dimension(209, 152));
        ontologyTagPanel.setMinimumSize(new java.awt.Dimension(209, 152));
        ontologyTagPanel.setPreferredSize(new java.awt.Dimension(209, 152));

        addOntologyTagButton.setText("Add Tag");
        addOntologyTagButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addOntologyTagButtonActionPerformed(evt);
            }
        });

        addOntologyTagTextField.setEnabled(false);
        addOntologyTagTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                addOntologyTagTextFieldKeyReleased(evt);
            }
        });

        categoryLabel.setText("Category");

        regionOntologyTag.setText("Select a Region");
        regionOntologyTag.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                regionOntologyTagActionPerformed(evt);
            }
        });
        regionOntologyTag.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                regionOntologyTagFocusLost(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 2, 11));
        jLabel1.setText("Optional");

        categoriesComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Choose a category" }));
        categoriesComboBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                categoriesComboBoxItemStateChanged(evt);
            }
        });

        javax.swing.GroupLayout ontologyTagPanelLayout = new javax.swing.GroupLayout(ontologyTagPanel);
        ontologyTagPanel.setLayout(ontologyTagPanelLayout);
        ontologyTagPanelLayout.setHorizontalGroup(
            ontologyTagPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ontologyTagPanelLayout.createSequentialGroup()
                .addGroup(ontologyTagPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ontologyTagPanelLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(addOntologyTagTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE))
                    .addGroup(ontologyTagPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(categoryLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
                        .addComponent(categoriesComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(ontologyTagPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(ontologyTagPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(regionOntologyTag, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)
                            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(ontologyTagPanelLayout.createSequentialGroup()
                        .addGap(57, 57, 57)
                        .addComponent(addOntologyTagButton, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        ontologyTagPanelLayout.setVerticalGroup(
            ontologyTagPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ontologyTagPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(addOntologyTagTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(ontologyTagPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(categoryLabel)
                    .addComponent(categoriesComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(regionOntologyTag)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(addOntologyTagButton)
                .addGap(80, 80, 80))
        );

        addTagTabbedPane.addTab("Ontology Tag", ontologyTagPanel);

        cancelTagButton.setText("Cancel");
        cancelTagButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelTagButtonActionPerformed(evt);
            }
        });

        acceptTagButton.setText("Accept");
        acceptTagButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                acceptTagButtonActionPerformed(evt);
            }
        });

        editedTagsScrollPane.setMaximumSize(new java.awt.Dimension(144, 130));
        editedTagsScrollPane.setMinimumSize(new java.awt.Dimension(144, 130));
        editedTagsScrollPane.setPreferredSize(new java.awt.Dimension(144, 130));

        editedTagsList.setModel(editedTagsModel);
        editedTagsList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        editedTagsList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                editedTagsListValueChanged(evt);
            }
        });
        editedTagsList.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                editedTagsListFocusLost(evt);
            }
        });
        editedTagsScrollPane.setViewportView(editedTagsList);

        deleteTagButton.setText("Delete Tag");
        deleteTagButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteTagButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout addTagInternalFrameLayout = new javax.swing.GroupLayout(addTagInternalFrame.getContentPane());
        addTagInternalFrame.getContentPane().setLayout(addTagInternalFrameLayout);
        addTagInternalFrameLayout.setHorizontalGroup(
            addTagInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(addTagInternalFrameLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(addTagTabbedPane, javax.swing.GroupLayout.PREFERRED_SIZE, 211, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(addTagInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(addTagInternalFrameLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(editedTagsScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, addTagInternalFrameLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(deleteTagButton, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(23, 23, 23)))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, addTagInternalFrameLayout.createSequentialGroup()
                .addContainerGap(103, Short.MAX_VALUE)
                .addComponent(acceptTagButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cancelTagButton, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(135, 135, 135))
        );
        addTagInternalFrameLayout.setVerticalGroup(
            addTagInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(addTagInternalFrameLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(addTagInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(addTagInternalFrameLayout.createSequentialGroup()
                        .addComponent(editedTagsScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(deleteTagButton))
                    .addComponent(addTagTabbedPane, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(addTagInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(acceptTagButton)
                    .addComponent(cancelTagButton))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        addTagInternalFrame.setBounds(75, 250, 401, 250);
        desktopPane.add(addTagInternalFrame, javax.swing.JLayeredPane.POPUP_LAYER);

        editionPanelContainer.setBackground(new java.awt.Color(255, 255, 255));
        editionPanelContainer.setMaximumSize(new java.awt.Dimension(550, 567));
        editionPanelContainer.setPreferredSize(new java.awt.Dimension(550, 567));

        editionPanel.setBackground(new java.awt.Color(255, 255, 255));
        editionPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102, 102, 102)));
        editionPanel.setMaximumSize(new java.awt.Dimension(541, 307));
        editionPanel.setMinimumSize(new java.awt.Dimension(541, 307));

        photoEditionPanel.setBackground(new java.awt.Color(255, 255, 255));
        photoEditionPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        photoEditionPanel.setMaximumSize(new java.awt.Dimension(429, 273));
        photoEditionPanel.setMinimumSize(new java.awt.Dimension(429, 273));
        photoEditionPanel.setPreferredSize(new java.awt.Dimension(429, 273));
        photoEditionPanel.setLayout(new javax.swing.BoxLayout(photoEditionPanel, javax.swing.BoxLayout.LINE_AXIS));

        photoScrollPane.setBackground(new java.awt.Color(255, 255, 255));
        photoScrollPane.setBorder(null);
        photoScrollPane.setMaximumSize(new java.awt.Dimension(600, 400));
        photoScrollPane.setMinimumSize(new java.awt.Dimension(400, 250));
        photoEditionPanel.add(photoScrollPane);

        palettePanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        saveButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/Save.png"))); // NOI18N
        saveButton.setToolTipText("Save changes");
        saveButton.setBorderPainted(false);
        saveButton.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/SaveDisabled.png"))); // NOI18N
        saveButton.setFocusPainted(false);
        saveButton.setMaximumSize(new java.awt.Dimension(52, 46));
        saveButton.setMinimumSize(new java.awt.Dimension(52, 46));
        saveButton.setPreferredSize(new java.awt.Dimension(52, 46));
        saveButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/SavePressed.png"))); // NOI18N
        saveButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/SaveRollover.png"))); // NOI18N
        saveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveButtonActionPerformed(evt);
            }
        });

        openImageButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/openImage.png"))); // NOI18N
        openImageButton.setToolTipText("Open image");
        openImageButton.setActionCommand("Open image");
        openImageButton.setBorderPainted(false);
        openImageButton.setFocusPainted(false);
        openImageButton.setMaximumSize(new java.awt.Dimension(52, 46));
        openImageButton.setMinimumSize(new java.awt.Dimension(52, 46));
        openImageButton.setPreferredSize(new java.awt.Dimension(52, 46));
        openImageButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/openImagePressed.png"))); // NOI18N
        openImageButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/openImageRollover.png"))); // NOI18N
        openImageButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                openImageButtonActionPerformed(evt);
            }
        });

        openImageButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/addImage.png"))); // NOI18N
        openImageButton1.setToolTipText("Import image");
        openImageButton1.setBorderPainted(false);
        openImageButton1.setFocusPainted(false);
        openImageButton1.setMaximumSize(new java.awt.Dimension(52, 46));
        openImageButton1.setMinimumSize(new java.awt.Dimension(52, 46));
        openImageButton1.setPreferredSize(new java.awt.Dimension(52, 46));
        openImageButton1.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/addImagePressed.png"))); // NOI18N
        openImageButton1.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/addImageRollover.png"))); // NOI18N
        openImageButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                openImageButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout optionsPanelLayout = new javax.swing.GroupLayout(optionsPanel);
        optionsPanel.setLayout(optionsPanelLayout);
        optionsPanelLayout.setHorizontalGroup(
            optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(optionsPanelLayout.createSequentialGroup()
                .addGroup(optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(openImageButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(saveButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(openImageButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        optionsPanelLayout.setVerticalGroup(
            optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(optionsPanelLayout.createSequentialGroup()
                .addComponent(saveButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(openImageButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(openImageButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        undoButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/Undo.png"))); // NOI18N
        undoButton.setToolTipText("Undo");
        undoButton.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/UndoDisabled.png"))); // NOI18N
        undoButton.setEnabled(false);
        undoButton.setMaximumSize(new java.awt.Dimension(32, 32));
        undoButton.setMinimumSize(new java.awt.Dimension(32, 32));
        undoButton.setPreferredSize(new java.awt.Dimension(32, 32));
        undoButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/UndoPressed.png"))); // NOI18N
        undoButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/UndoRollover.png"))); // NOI18N
        undoButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                undoButtonActionPerformed(evt);
            }
        });

        sharpButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/sharpening.png"))); // NOI18N
        sharpButton.setToolTipText("Sharpening");
        sharpButton.setBorderPainted(false);
        sharpButton.setFocusPainted(false);
        sharpButton.setMaximumSize(new java.awt.Dimension(32, 32));
        sharpButton.setMinimumSize(new java.awt.Dimension(32, 32));
        sharpButton.setPreferredSize(new java.awt.Dimension(32, 32));
        sharpButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/sharpeningPressed.png"))); // NOI18N
        sharpButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/sharpeningRollover.png"))); // NOI18N
        sharpButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sharpButtonActionPerformed(evt);
            }
        });

        blurButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/blurring.png"))); // NOI18N
        blurButton.setToolTipText("Blurring");
        blurButton.setBorderPainted(false);
        blurButton.setFocusPainted(false);
        blurButton.setMaximumSize(new java.awt.Dimension(32, 32));
        blurButton.setMinimumSize(new java.awt.Dimension(32, 32));
        blurButton.setPreferredSize(new java.awt.Dimension(32, 32));
        blurButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/blurringPressed.png"))); // NOI18N
        blurButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/blurringRollover.png"))); // NOI18N
        blurButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                blurButtonActionPerformed(evt);
            }
        });

        contrastButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/Contrast.png"))); // NOI18N
        contrastButton.setToolTipText("Contrast / Brightness");
        contrastButton.setBorderPainted(false);
        contrastButton.setFocusPainted(false);
        contrastButton.setMaximumSize(new java.awt.Dimension(32, 32));
        contrastButton.setMinimumSize(new java.awt.Dimension(32, 32));
        contrastButton.setPreferredSize(new java.awt.Dimension(32, 32));
        contrastButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/ContrastPressed.png"))); // NOI18N
        contrastButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/ContrastRollover.png"))); // NOI18N
        contrastButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                contrastButtonActionPerformed(evt);
            }
        });

        redoButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/Redo.png"))); // NOI18N
        redoButton.setToolTipText("Redo");
        redoButton.setBorderPainted(false);
        redoButton.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/RedoDisabled.png"))); // NOI18N
        redoButton.setEnabled(false);
        redoButton.setFocusPainted(false);
        redoButton.setMaximumSize(new java.awt.Dimension(32, 32));
        redoButton.setMinimumSize(new java.awt.Dimension(32, 32));
        redoButton.setPreferredSize(new java.awt.Dimension(32, 32));
        redoButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/RedoPressed.png"))); // NOI18N
        redoButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/RedoRollover.png"))); // NOI18N
        redoButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                redoButtonActionPerformed(evt);
            }
        });

        edgeDetectionButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/edgeDetection.png"))); // NOI18N
        edgeDetectionButton.setToolTipText("Edge detection");
        edgeDetectionButton.setBorderPainted(false);
        edgeDetectionButton.setFocusPainted(false);
        edgeDetectionButton.setMaximumSize(new java.awt.Dimension(32, 32));
        edgeDetectionButton.setMinimumSize(new java.awt.Dimension(32, 32));
        edgeDetectionButton.setPreferredSize(new java.awt.Dimension(32, 32));
        edgeDetectionButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/edgeDetectionPressed.png"))); // NOI18N
        edgeDetectionButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/edgeDetectionRollover.png"))); // NOI18N
        edgeDetectionButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                edgeDetectionButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout palettePanelLayout = new javax.swing.GroupLayout(palettePanel);
        palettePanel.setLayout(palettePanelLayout);
        palettePanelLayout.setHorizontalGroup(
            palettePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(palettePanelLayout.createSequentialGroup()
                .addGroup(palettePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, palettePanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(optionsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, palettePanelLayout.createSequentialGroup()
                        .addComponent(undoButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(redoButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, palettePanelLayout.createSequentialGroup()
                        .addGroup(palettePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(contrastButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(sharpButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(palettePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(blurButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(edgeDetectionButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
        );
        palettePanelLayout.setVerticalGroup(
            palettePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(palettePanelLayout.createSequentialGroup()
                .addGroup(palettePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(undoButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(redoButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(palettePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(contrastButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(edgeDetectionButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(palettePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(blurButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(sharpButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(optionsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        deleteButton.setBackground(new java.awt.Color(255, 255, 255));
        deleteButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/Delete.png"))); // NOI18N
        deleteButton.setToolTipText("Delete");
        deleteButton.setBorderPainted(false);
        deleteButton.setFocusPainted(false);
        deleteButton.setMaximumSize(new java.awt.Dimension(24, 18));
        deleteButton.setMinimumSize(new java.awt.Dimension(24, 18));
        deleteButton.setPreferredSize(new java.awt.Dimension(24, 18));
        deleteButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/DeletePressed.png"))); // NOI18N
        deleteButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/DeleteRollover.png"))); // NOI18N
        deleteButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteButtonActionPerformed(evt);
            }
        });

        titleView.setFont(new java.awt.Font("Verdana", 1, 12));
        titleView.setText("Title");

        dateView.setText("(02 - 06 - 2008)");

        addTagButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/addTag.png"))); // NOI18N
        addTagButton.setText("Edit Tags");
        addTagButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addTagButtonActionPerformed(evt);
            }
        });

        tagsComboBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                tagsComboBoxItemStateChanged(evt);
            }
        });
        tagsComboBox.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tagsComboBoxFocusLost(evt);
            }
        });

        tagsLabel.setText("Tags");

        javax.swing.GroupLayout editionPanelLayout = new javax.swing.GroupLayout(editionPanel);
        editionPanel.setLayout(editionPanelLayout);
        editionPanelLayout.setHorizontalGroup(
            editionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(editionPanelLayout.createSequentialGroup()
                .addGroup(editionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(editionPanelLayout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(titleView)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(dateView)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(deleteButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, editionPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(editionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(photoEditionPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 432, Short.MAX_VALUE)
                            .addGroup(editionPanelLayout.createSequentialGroup()
                                .addComponent(tagsLabel)
                                .addGap(18, 18, 18)
                                .addComponent(tagsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 38, Short.MAX_VALUE)
                                .addComponent(addTagButton)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(palettePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        editionPanelLayout.setVerticalGroup(
            editionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(editionPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(editionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(deleteButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(editionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(titleView)
                        .addComponent(dateView)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(editionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(photoEditionPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(palettePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 273, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(editionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(addTagButton, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tagsLabel)
                    .addComponent(tagsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        metadataPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102, 102, 102)));
        metadataPanel.setMaximumSize(new java.awt.Dimension(541, 238));
        metadataPanel.setMinimumSize(new java.awt.Dimension(541, 0));
        metadataPanel.setPreferredSize(new java.awt.Dimension(541, 238));

        updatePropertiesButton.setText("Update");
        updatePropertiesButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                updatePropertiesButtonActionPerformed(evt);
            }
        });

        generalPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "General", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N

        titleLabel.setText("Title");

        subjectLabel.setText("Subject");

        descriptionLabel.setText("Description");

        sourceLabel.setText("Source");

        description.setColumns(20);
        description.setRows(5);
        jScrollPane1.setViewportView(description);

        javax.swing.GroupLayout generalPanelLayout = new javax.swing.GroupLayout(generalPanel);
        generalPanel.setLayout(generalPanelLayout);
        generalPanelLayout.setHorizontalGroup(
            generalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(generalPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(generalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(generalPanelLayout.createSequentialGroup()
                        .addGroup(generalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(subjectLabel)
                            .addComponent(titleLabel))
                        .addGroup(generalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(generalPanelLayout.createSequentialGroup()
                                .addGap(37, 37, 37)
                                .addComponent(title))
                            .addGroup(generalPanelLayout.createSequentialGroup()
                                .addGap(38, 38, 38)
                                .addGroup(generalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(source)
                                    .addComponent(subject, javax.swing.GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE))))
                        .addGap(14, 14, 14)
                        .addComponent(descriptionLabel))
                    .addComponent(sourceLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 240, Short.MAX_VALUE)
                .addContainerGap())
        );
        generalPanelLayout.setVerticalGroup(
            generalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(generalPanelLayout.createSequentialGroup()
                .addGroup(generalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(title, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(titleLabel)
                    .addComponent(descriptionLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(generalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(subject, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(subjectLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(generalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sourceLabel)
                    .addComponent(source, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        intellectualpanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Intellectual Properties", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N

        creatorLabel.setText("Creator");

        publisherLabel.setText("Publisher");

        contributorLabel.setText("Contributor");

        rightsLabel.setText("Rights");

        javax.swing.GroupLayout intellectualpanelLayout = new javax.swing.GroupLayout(intellectualpanel);
        intellectualpanel.setLayout(intellectualpanelLayout);
        intellectualpanelLayout.setHorizontalGroup(
            intellectualpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(intellectualpanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(intellectualpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(publisherLabel)
                    .addComponent(creatorLabel))
                .addGap(31, 31, 31)
                .addGroup(intellectualpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(creator, javax.swing.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE)
                    .addComponent(publisher))
                .addGap(18, 18, 18)
                .addGroup(intellectualpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(contributorLabel)
                    .addComponent(rightsLabel))
                .addGap(18, 18, 18)
                .addGroup(intellectualpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(rights, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE)
                    .addComponent(contributor, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE))
                .addContainerGap())
        );
        intellectualpanelLayout.setVerticalGroup(
            intellectualpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(intellectualpanelLayout.createSequentialGroup()
                .addGroup(intellectualpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(creatorLabel)
                    .addComponent(creator, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(contributor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(contributorLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(intellectualpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(publisherLabel)
                    .addComponent(publisher, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(rights, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(rightsLabel)))
        );

        resetPropertiesButton.setText("Reset");
        resetPropertiesButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                resetPropertiesButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout metadataPanelLayout = new javax.swing.GroupLayout(metadataPanel);
        metadataPanel.setLayout(metadataPanelLayout);
        metadataPanelLayout.setHorizontalGroup(
            metadataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, metadataPanelLayout.createSequentialGroup()
                .addComponent(intellectualpanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(metadataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(updatePropertiesButton, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(resetPropertiesButton, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
            .addComponent(generalPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        metadataPanelLayout.setVerticalGroup(
            metadataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(metadataPanelLayout.createSequentialGroup()
                .addComponent(generalPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(metadataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(intellectualpanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(metadataPanelLayout.createSequentialGroup()
                        .addComponent(updatePropertiesButton, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(resetPropertiesButton, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout editionPanelContainerLayout = new javax.swing.GroupLayout(editionPanelContainer);
        editionPanelContainer.setLayout(editionPanelContainerLayout);
        editionPanelContainerLayout.setHorizontalGroup(
            editionPanelContainerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, editionPanelContainerLayout.createSequentialGroup()
                .addGroup(editionPanelContainerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(metadataPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(editionPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        editionPanelContainerLayout.setVerticalGroup(
            editionPanelContainerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(editionPanelContainerLayout.createSequentialGroup()
                .addComponent(editionPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(metadataPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(49, 49, 49))
        );

        editionPanelContainer.setBounds(0, 0, 550, 560);
        desktopPane.add(editionPanelContainer, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 546, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 595, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void contrastSliderMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_contrastSliderMouseDragged
        if (previewButton.isSelected()) {
            int contrasting = contrastSlider.getValue();
            Contrast c = new Contrast();
            PlanarImage ro = c.execute(image, contrasting);
            img.set(ro);
            update();
        }
        contrastTextField.setText("" + contrastSlider.getValue());
    }//GEN-LAST:event_contrastSliderMouseDragged
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void edgeDetectionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_edgeDetectionButtonActionPerformed
        updateHistory();
        EdgeDetection ed = new EdgeDetection();
        image = ed.execute(image);
        img.set(image);
        Object[] a = {"edge detection", image, contrastSlider.getValue(),
        brightnessSlider.getValue()};
        history.add(a);
        update();
        undoButton.setEnabled(true);
        saveButton.setEnabled(true);
        redoButton.setEnabled(false);
}//GEN-LAST:event_edgeDetectionButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void blurButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_blurButtonActionPerformed
        updateHistory();
        Blurring ed = new Blurring();
        image = ed.execute(image);
        img.set(image);
        Object[] a = {"blurring", image, contrastSlider.getValue(),
        brightnessSlider.getValue()};
        history.add(a);
        update();
        undoButton.setEnabled(true);
        saveButton.setEnabled(true);
        redoButton.setEnabled(false);
}//GEN-LAST:event_blurButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void sharpButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sharpButtonActionPerformed
        updateHistory();
        Sharp s = new Sharp();
        image = s.execute(image);
        img.set(image);
        Object[] a = {"sharpening", image, contrastSlider.getValue(),
        brightnessSlider.getValue()};
        history.add(a);
        update();
        undoButton.setEnabled(true);
        saveButton.setEnabled(true);
        redoButton.setEnabled(false);
}//GEN-LAST:event_sharpButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void undoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_undoButtonActionPerformed
        historyIndex--;
        image = (PlanarImage) (history.get(historyIndex))[1];
        contrastSlider.setValue((Integer) (history.get(historyIndex))[2]);
        contrastTextField.setText("" + contrastSlider.getValue());
        brightnessSlider.setValue((Integer) (history.get(historyIndex))[3]);
        brightnessTextField.setText("" + brightnessSlider.getValue());
        img.set(image);
        update();
        if (historyIndex == 0) {
            undoButton.setEnabled(false);
        }
        redoButton.setEnabled(true);
}//GEN-LAST:event_undoButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void redoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_redoButtonActionPerformed
        historyIndex++;
        image = (PlanarImage) (history.get(historyIndex))[1];
        img.set(image);
        contrastSlider.setValue((Integer) (history.get(historyIndex))[2]);
        contrastTextField.setText("" + contrastSlider.getValue());
        brightnessSlider.setValue((Integer) (history.get(historyIndex))[3]);
        brightnessTextField.setText("" + brightnessSlider.getValue());
        update();
        if (historyIndex == history.size() - 1) {
            redoButton.setEnabled(false);
        }
        undoButton.setEnabled(true);
        saveButton.setEnabled(true);
}//GEN-LAST:event_redoButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void contrastButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_contrastButtonActionPerformed
        // TODO add your handling code here:
        contrastInternalFrame.setVisible(true);
        contrastInternalFrame.setLocation(100, 200);
        update();
    }//GEN-LAST:event_contrastButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void acceptButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_acceptButtonActionPerformed
        // TODO add your handling code here:
        updateHistory();
        int contrasting = contrastSlider.getValue();
        Contrast c = new Contrast();
        image = c.execute(image, contrasting);
        int brightness = brightnessSlider.getValue();
        Brightness b = new Brightness();
        image = b.execute(image, brightness);
        img.set(image);
        update();
        Object[] a = {"contrast", image, contrastSlider.getValue(),
        brightnessSlider.getValue()};
        history.add(a);
        undoButton.setEnabled(true);
        saveButton.setEnabled(true);
        redoButton.setEnabled(false);
        contrastInternalFrame.setVisible(false);
    }//GEN-LAST:event_acceptButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
        // TODO add your handling code here:
        contrastInternalFrame.setVisible(false);
        image = (PlanarImage) (history.get(historyIndex))[1];
        img.set(image);
        update();
        contrastSlider.setValue((Integer) (history.get(historyIndex))[2]);
        contrastTextField.setText("" + contrastSlider.getValue());
        brightnessSlider.setValue((Integer) (history.get(historyIndex))[3]);
        brightnessTextField.setText("" + brightnessSlider.getValue());
    }//GEN-LAST:event_cancelButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteButtonActionPerformed
        // TODO add your handling code here:
        deleteInternalFrame.setVisible(true);
        deleteInternalFrame.setLocation(50, 50);
        update();
    }//GEN-LAST:event_deleteButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void deleteNoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteNoButtonActionPerformed
        // TODO add your handling code here:
        deleteInternalFrame.setVisible(false);
    }//GEN-LAST:event_deleteNoButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void deleteYesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteYesButtonActionPerformed
        // TODO add your handling code here:
        deleteInternalFrame.setVisible(false);
        File parent = file.getParentFile();
        if (deletePhoto()) {
            p2piki.updateTreeExplorer(0);
            p2piki.directorySelected(0, parent);
            p2piki.showListExplorer(0);
        }
    }//GEN-LAST:event_deleteYesButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void openImageButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openImageButtonActionPerformed
        // TODO add your handling code here:
        FileSystemView fsv = new FileChooser(
                new File(grupb.upf.util.Config.getProperty("photo.folder"))
                .getAbsoluteFile());
        JFileChooser fc = new JFileChooser(fsv);
        fc.setCurrentDirectory(file.getParentFile());
        fc.setFileSelectionMode(javax.swing.JFileChooser.FILES_ONLY);
        if (fc.showOpenDialog(desktopPane) == JFileChooser.APPROVE_OPTION) {
            final String path = fc.getSelectedFile().getAbsolutePath();
            boolean isPhoto = false;
            //format
            final String extension =
                    path.substring(path.lastIndexOf(".") + 1);
            for (int i = 0; i < PHOTO_FORMATS.length; i++) {
                if (PHOTO_FORMATS[i].equalsIgnoreCase(extension)) {
                    isPhoto = true;
                }
            }
            if (isPhoto) {
                setPhoto(fc.getSelectedFile());
            } else {
                p2piki.addError("It isn't an accepted format.");
            }
        }
    }//GEN-LAST:event_openImageButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
        // TODO add your handling code here:
        qualityInternalFrame.setVisible(true);
        qualityInternalFrame.setLocation(100, 200);
        update();
    }//GEN-LAST:event_saveButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void addTagButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addTagButtonActionPerformed
        // TODO add your handling code here:
        addTagInternalFrame.setVisible(true);
        addTagInternalFrame.setLocation(75, 250);
        update();
    }//GEN-LAST:event_addTagButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void acceptTagButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_acceptTagButtonActionPerformed
        // TODO add your handling code here:
        removeAnnotations();
        addTagInternalFrame.setVisible(false);
        auxTagsList.clear();
        tagsComboBox.removeAllItems();
        tagsComboBox.addItem("-------------------- Tags ---------------------");
        for (int i = 0; i < auxEditedTagsList.size(); i++) {
            auxTagsList.add(auxEditedTagsList.get(i));
            tagsComboBox.addItem(auxEditedTagsList.get(i).getTag());
        }
    }//GEN-LAST:event_acceptTagButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void cancelTagButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelTagButtonActionPerformed
        // TODO add your handling code here:
        removeAnnotations();
        auxEditedTagsList.clear();
        editedTagsModel.removeAllElements();
        for (int i = 0; i < auxTagsList.size(); i++) {
            auxEditedTagsList.add(auxTagsList.get(i));
            editedTagsModel.addElement(
                    ((Tag) auxTagsList.get(i)).getTag());
        }
        addTagInternalFrame.setVisible(false);
    }//GEN-LAST:event_cancelTagButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void tagsComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_tagsComboBoxItemStateChanged
        // TODO add your handling code here:
        removeAnnotations();
        if (tagsComboBox.getSelectedItem() != null &&
                tagsComboBox.getSelectedIndex() != 0) {
            Tag tag = auxTagsList.get(
                    tagsComboBox.getSelectedIndex() - 1);
            if (tag.getCoordenates() != null) {
                int[] points = new int[4];
                points[0] = (Integer) tag.getCoordenates().get("x1");
                points[1] = (Integer) tag.getCoordenates().get("y1");
                points[2] = (Integer) tag.getCoordenates().get("x2");
                points[3] = (Integer) tag.getCoordenates().get("y2");
                TagAnnotation c2 = new TagAnnotation(points);
                c2.setColor(Color.BLACK);
                img.addAnnotation(c2);
                update();
            }
        }

    }//GEN-LAST:event_tagsComboBoxItemStateChanged
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void tagsComboBoxFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tagsComboBoxFocusLost
        // TODO add your handling code here:
        removeAnnotations();
    }//GEN-LAST:event_tagsComboBoxFocusLost
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void deleteTagButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteTagButtonActionPerformed
        // TODO add your handling code here:
        if (editedTagsList.getSelectedValue() != null) {
            auxEditedTagsList.remove(editedTagsList.getSelectedIndex());
            editedTagsModel.removeElementAt(editedTagsList.getSelectedIndex());
        }
    }//GEN-LAST:event_deleteTagButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void resetPropertiesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resetPropertiesButtonActionPerformed
        // TODO add your handling code here:
        getProperties();
}//GEN-LAST:event_resetPropertiesButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void regionOntologyTag1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_regionOntologyTag1ActionPerformed
        // TODO add your handling code here:
        paintTags = true;
    }//GEN-LAST:event_regionOntologyTag1ActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void addPersonalTagButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addPersonalTagButtonActionPerformed
        // TODO add your handling code here:
        if (addTagTextField.getText().trim().length() == 0) {
            p2piki.addError("You can't add a void tag.");
        } else {
            Tag tag = new PersonalTag();
            tag.setTag(addTagTextField.getText().trim());
            if (coordenates != null) {
                tag.setCoordenates(coordenates[0], coordenates[2],
                        coordenates[1], coordenates[3]);
                coordenates = new int[4];
            }
            addTagTextField.setText("");
            auxEditedTagsList.add(tag);
            editedTagsModel.addElement(tag.getTag());
            coordenates = null;
            img.resetClics();
        }
        removeAnnotations();
}//GEN-LAST:event_addPersonalTagButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void regionOntologyTag1FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_regionOntologyTag1FocusLost
        // TODO add your handling code here:
        paintTags = false;
    }//GEN-LAST:event_regionOntologyTag1FocusLost
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void addTagInternalFrameFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_addTagInternalFrameFocusLost
        // TODO add your handling code here:
        removeAnnotations();
    }//GEN-LAST:event_addTagInternalFrameFocusLost
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void editedTagsListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_editedTagsListValueChanged
        // TODO add your handling code here:
        removeAnnotations();
        if (editedTagsList.getSelectedValue() != null) {
            Tag tag = auxEditedTagsList.get(
                    editedTagsList.getSelectedIndex());
            if (tag.getCoordenates() != null) {
                int[] points = new int[4];
                points[0] = (Integer) tag.getCoordenates().get("x1");
                points[1] = (Integer) tag.getCoordenates().get("y1");
                points[2] = (Integer) tag.getCoordenates().get("x2");
                points[3] = (Integer) tag.getCoordenates().get("y2");
                TagAnnotation c2 = new TagAnnotation(points);
                c2.setColor(Color.RED);
                img.addAnnotation(c2);
                update();
            }
        }
    }//GEN-LAST:event_editedTagsListValueChanged
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void editedTagsListFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_editedTagsListFocusLost
        // TODO add your handling code here:
        removeAnnotations();
    }//GEN-LAST:event_editedTagsListFocusLost
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void categoriesComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_categoriesComboBoxItemStateChanged
        // TODO add your handling code here:
        if (categoriesComboBox.getSelectedIndex() > 0) {
            addOntologyTagTextField.setEnabled(true);
            addOntologyTagTextField.setText("");
        } else {
            addOntologyTagTextField.setEnabled(false);
            addOntologyTagTextField.setText("Choose a category");
        }
}//GEN-LAST:event_categoriesComboBoxItemStateChanged
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void addOntologyTagTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_addOntologyTagTextFieldKeyReleased
        // TODO add your handling code here:
        String text = addOntologyTagTextField.getText();
        List tax = (List) taxonomies.get(categoriesComboBox
                .getSelectedIndex() - 1);
        Collections.sort(tax);
        ontologiesPopupMenu = new javax.swing.JPopupMenu();
        for (int i = 1; i < tax.size(); i++) {
            if (((String) tax.get(i)).toLowerCase().startsWith(
                    text.toLowerCase())) {
                final javax.swing.JMenuItem item =
                        new javax.swing.JMenuItem(
                        (String) tax.get(i));
                item.addActionListener(
                        new java.awt.event.ActionListener() {

                            @Override
                            public void actionPerformed(
                                    java.awt.event.ActionEvent e) {
                                addOntologyTagTextField.setText(
                                        item.getText());
                            }
                        });
                ontologiesPopupMenu.add(item);
            }
        }
        ontologiesPopupMenu.show(addOntologyTagTextField,
                addOntologyTagTextField.getX() - 5,
                addOntologyTagTextField.getY() + 10);
        addOntologyTagTextField.grabFocus();
    }//GEN-LAST:event_addOntologyTagTextFieldKeyReleased
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void regionOntologyTagActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_regionOntologyTagActionPerformed
        // TODO add your handling code here:
        paintTags = true;
    }//GEN-LAST:event_regionOntologyTagActionPerformed

    private void addOntologyTagButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addOntologyTagButtonActionPerformed
        // TODO add your handling code here:
        if (addOntologyTagTextField.getText().trim().length() == 0
                || !addOntologyTagTextField.isEnabled()) {
            p2piki.addError("You can't add a void tag or without a category.");
        } else {
            String keyword = addOntologyTagTextField.getText().trim();
            boolean keywordExists = false;
            List taxonomy;
            for (int i = 0; i < taxonomies.size(); i++) {
                taxonomy = (List) taxonomies.get(i);
                for (int j = 0; j < taxonomy.size(); j++) {
                    if (((String) taxonomy.get(j)).equals(keyword)) {
                        keywordExists = true;
                    }
                }
            }
            if (!keywordExists) {
                p2piki.addError("The Tag doesn't exist in the database.");
                return;
            }
            PredefinedTag tag = new PredefinedTag();
            tag.setTag(addOntologyTagTextField.getText().trim());
            tag.setCategory((String) categoriesComboBox.getSelectedItem());
            if (coordenates != null) {
                tag.setCoordenates(coordenates[0], coordenates[2],
                        coordenates[1], coordenates[3]);
            }
            coordenates = null;
            addOntologyTagTextField.setText("");
            auxEditedTagsList.add(tag);
            editedTagsModel.addElement(tag.getTag());
        }
        removeAnnotations();
    }//GEN-LAST:event_addOntologyTagButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void regionOntologyTagFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_regionOntologyTagFocusLost
        // TODO add your handling code here:
        paintTags = false;
    }//GEN-LAST:event_regionOntologyTagFocusLost
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void deleteYesButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteYesButton1ActionPerformed
        // TODO add your handling code here:
        deletePreviousInternalFrame.setVisible(false);
        deletePhoto();
        storePhotoData();
    }//GEN-LAST:event_deleteYesButton1ActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void deleteNoButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteNoButton1ActionPerformed
        // TODO add your handling code here:
        deletePreviousInternalFrame.setVisible(false);
        storePhotoData();
    }//GEN-LAST:event_deleteNoButton1ActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void openImageButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openImageButton1ActionPerformed
        // TODO add your handling code here:
        JFileChooser fc = new JFileChooser();
        fc.setFileSelectionMode(javax.swing.JFileChooser.FILES_ONLY);
        if (fc.showOpenDialog(desktopPane) == JFileChooser.APPROVE_OPTION) {
            final String path = fc.getSelectedFile().getAbsolutePath();
            boolean isPhoto = false;
            //format
            final String extension =
                    path.substring(path.lastIndexOf(".") + 1);
            for (int i = 0; i < PHOTO_FORMATS.length; i++) {
                if (PHOTO_FORMATS[i].equalsIgnoreCase(extension)) {
                    isPhoto = true;
                }
            }
            if (isPhoto) {
                setPhoto(fc.getSelectedFile());
            } else {
                p2piki.addError("It isn't an accepted format.");
            }
        }
    }//GEN-LAST:event_openImageButton1ActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void updatePropertiesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updatePropertiesButtonActionPerformed
        // TODO add your handling code here:
        updateProperties();
}//GEN-LAST:event_updatePropertiesButtonActionPerformed

    private void qualityOkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_qualityOkButtonActionPerformed
        // TODO add your handling code here:
        qualityInternalFrame.setVisible(false);
        FileSystemView fsv = new FileChooser(
                new File(grupb.upf.util.Config.getProperty("photo.folder"))
                .getAbsoluteFile());
        JFileChooser fc = new JFileChooser(fsv);
        FileFilter ff = new FileFilter() {

            @Override
            public boolean accept(final File f) {
                return true;
            }

            @Override
            public String getDescription() {
                return "Only supported .jpg or .jpg images.";
            }
        };
        fc.setApproveButtonText("Save");
        fc.setApproveButtonToolTipText("Save");
        fc.setDialogTitle("Save the image");
        fc.setFileFilter(ff);
        fc.setCurrentDirectory(file.getParentFile());
        String path = file.getAbsolutePath();

        boolean isPhoto = false;
        //format
        String extension = path.substring(path.lastIndexOf(".") + 1);
        for (int i = 0; i < PHOTO_FORMATS.length; i++) {
            if (PHOTO_FORMATS[i].equalsIgnoreCase(extension)) {
                isPhoto = true;
            }
        }
        if (!isPhoto) {
            path = path.substring(0, path.lastIndexOf(".") + 1) + "jpg";
        }
        fc.setSelectedFile(new File(path));
        if (fc.showOpenDialog(desktopPane) == JFileChooser.APPROVE_OPTION) {

            isPhoto = false;
            //format
            extension =
                    fc.getSelectedFile().getAbsolutePath().substring(
                    fc.getSelectedFile().getAbsolutePath().lastIndexOf(".")
                    + 1);
            for (int i = 0; i < PHOTO_FORMATS.length; i++) {
                if (PHOTO_FORMATS[i].equalsIgnoreCase(extension)) {
                    isPhoto = true;
                }
            }
            if (!isPhoto) {
                p2piki.addError("Format not supported.");
            } else {
                if (!fc.getSelectedFile().getAbsolutePath()
                        .equalsIgnoreCase(file.getAbsolutePath())) {
                    auxFile = fc.getSelectedFile().getAbsoluteFile();
                    Store s = new Store();
                    s.store(fc.getSelectedFile().getAbsolutePath(),
                        (PlanarImage) (history.get(historyIndex))[1],
                        qualitySlider.getValue());
                    deletePreviousInternalFrame.setLocation(150, 150);
                    deletePreviousInternalFrame.setVisible(true);
                } else {
                    Store s = new Store();
                    s.store(fc.getSelectedFile().getAbsolutePath(),
                        (PlanarImage) (history.get(historyIndex))[1],
                        qualitySlider.getValue());
                    if (photo == null || photo.getID() == -1) {
                        if (LOG.isInfoEnabled()) {
                            auxFile = fc.getSelectedFile().getAbsoluteFile();
                            storePhotoData();
                        }
                    } else {
                        updateProperties();
                    }
                }
            }
        }
}//GEN-LAST:event_qualityOkButtonActionPerformed

    private void qualityCancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_qualityCancelButtonActionPerformed
        // TODO add your handling code here:
        qualityInternalFrame.setVisible(false);
        qualitySlider.setValue(100);
        qualityTextField.setText("100");
}//GEN-LAST:event_qualityCancelButtonActionPerformed

    private void qualitySliderMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_qualitySliderMouseDragged
        // TODO add your handling code here:
        qualityTextField.setText(qualitySlider.getValue() + "");
}//GEN-LAST:event_qualitySliderMouseDragged

    private void brightnessSliderMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_brightnessSliderMouseDragged
        // TODO add your handling code here:
        if (previewButton.isSelected()) {
            int brightness = brightnessSlider.getValue();
            Brightness b = new Brightness();
            PlanarImage ro = b.execute(image, brightness);
            img.set(ro);
            update();
        }
        brightnessTextField.setText("" + brightnessSlider.getValue());
}//GEN-LAST:event_brightnessSliderMouseDragged

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton acceptButton;
    private javax.swing.JButton acceptTagButton;
    private javax.swing.JButton addOntologyTagButton;
    private javax.swing.JTextField addOntologyTagTextField;
    private javax.swing.JButton addPersonalTagButton;
    private javax.swing.JButton addTagButton;
    private javax.swing.JInternalFrame addTagInternalFrame;
    private javax.swing.JTabbedPane addTagTabbedPane;
    private javax.swing.JTextField addTagTextField;
    private javax.swing.JButton blurButton;
    private javax.swing.JPanel brightnessPanel;
    private javax.swing.JSlider brightnessSlider;
    private javax.swing.JTextField brightnessTextField;
    private javax.swing.JButton cancelButton;
    private javax.swing.JButton cancelTagButton;
    private javax.swing.JComboBox categoriesComboBox;
    private javax.swing.JLabel categoryLabel;
    private javax.swing.JButton contrastButton;
    private javax.swing.JInternalFrame contrastInternalFrame;
    private javax.swing.JPanel contrastPanel;
    private javax.swing.JSlider contrastSlider;
    private javax.swing.JTextField contrastTextField;
    private javax.swing.JTextField contributor;
    private javax.swing.JLabel contributorLabel;
    private javax.swing.JTextField creator;
    private javax.swing.JLabel creatorLabel;
    private javax.swing.JLabel dateView;
    private javax.swing.JButton deleteButton;
    private javax.swing.JInternalFrame deleteInternalFrame;
    private javax.swing.JButton deleteNoButton;
    private javax.swing.JButton deleteNoButton1;
    private javax.swing.JInternalFrame deletePreviousInternalFrame;
    private javax.swing.JButton deleteTagButton;
    private javax.swing.JButton deleteYesButton;
    private javax.swing.JButton deleteYesButton1;
    private javax.swing.JTextArea description;
    private javax.swing.JLabel descriptionLabel;
    private javax.swing.JDesktopPane desktopPane;
    private javax.swing.JButton edgeDetectionButton;
    private javax.swing.JList editedTagsList;
    private javax.swing.JScrollPane editedTagsScrollPane;
    private javax.swing.JPanel editionPanel;
    private javax.swing.JPanel editionPanelContainer;
    private javax.swing.JPanel generalPanel;
    private javax.swing.JPanel intellectualpanel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JPanel metadataPanel;
    private javax.swing.JPopupMenu ontologiesPopupMenu;
    private javax.swing.JPanel ontologyTagPanel;
    private javax.swing.JButton openImageButton;
    private javax.swing.JButton openImageButton1;
    private javax.swing.JPanel optionsPanel;
    private javax.swing.JPanel palettePanel;
    private javax.swing.JPanel personalTagPanel;
    private javax.swing.JPanel photoEditionPanel;
    private javax.swing.JScrollPane photoScrollPane;
    private javax.swing.JCheckBox previewButton;
    private javax.swing.JCheckBox previewButton1;
    private javax.swing.JTextField publisher;
    private javax.swing.JLabel publisherLabel;
    private javax.swing.JButton qualityCancelButton;
    private javax.swing.JInternalFrame qualityInternalFrame;
    private javax.swing.JButton qualityOkButton;
    private javax.swing.JSlider qualitySlider;
    private javax.swing.JTextField qualityTextField;
    private javax.swing.JButton redoButton;
    private javax.swing.JButton regionOntologyTag;
    private javax.swing.JButton regionOntologyTag1;
    private javax.swing.JButton resetPropertiesButton;
    private javax.swing.JTextField rights;
    private javax.swing.JLabel rightsLabel;
    private javax.swing.JButton saveButton;
    private javax.swing.JButton sharpButton;
    private javax.swing.JTextField source;
    private javax.swing.JLabel sourceLabel;
    private javax.swing.JTextField subject;
    private javax.swing.JLabel subjectLabel;
    private javax.swing.JComboBox tagsComboBox;
    private javax.swing.JLabel tagsLabel;
    private javax.swing.JTextField title;
    private javax.swing.JLabel titleLabel;
    private javax.swing.JLabel titleView;
    private javax.swing.JButton undoButton;
    private javax.swing.JButton updatePropertiesButton;
    // End of variables declaration//GEN-END:variables
}
